﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateSiteCollection.aspx.cs" Inherits="DissingConsulting.CreateHostNamedSiteCollection.CreateSiteCollectionPage" DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="~/_controltemplates/15/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="~/_controltemplates/15/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="~/_controltemplates/15/ButtonSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="TemplatePickerControl" Src="~/_controltemplates/15/TemplatePickerControl.ascx" %>
<%@ Register TagPrefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <style type="text/css">
        .codeSnippetContainer {
            clear: both;
            min-width: 260px;
        }

        .codeSnippetContainerTabs {
            height: 23px;
            vertical-align: middle;
            position: relative;
            z-index: 1;
        }

        .codeSnippetContainerTab {
            width: auto;
            height: 22px;
            color: #2a2a2a;
            padding-top: 0px;
            padding-right: 15px;
            padding-bottom: 0px;
            padding-left: 15px;
            font-family: "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif !important;
            font-size: 12px;
            font-style: normal !important;
            vertical-align: baseline;
            float: left;
        }

        .codeSnippetContainerTabActive {
            width: auto;
            height: 22px;
            color: #707070;
            padding-top: 0px;
            padding-right: 15px;
            padding-bottom: 0px;
            padding-left: 15px;
            font-family: "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif !important;
            font-size: 12px;
            font-style: normal !important;
            vertical-align: baseline;
            border-top-color: #939393;
            border-right-color: #939393;
            border-left-color: #939393;
            border-top-width: 1px;
            border-right-width: 1px;
            border-left-width: 1px;
            border-top-style: solid;
            border-right-style: solid;
            border-left-style: solid;
            float: left;
            background-image: none;
            background-attachment: scroll;
            background-repeat: repeat;
            background-position-x: 0%;
            background-position-y: 0%;
            background-size: auto;
            background-origin: padding-box;
            background-clip: border-box;
            background-color: rgb(248, 248, 248);
        }

        .codeSnippetContainerTab a, .codeSnippetContainerTab a:link, .codeSnippetContainerTab a:visited, .codeSnippetContainerTab a:active {
            top: 2px;
            color: #2a2a2a;
            text-decoration: none;
            position: relative;
        }

        .codeSnippetContainerTabActive a, .codeSnippetContainerTabActive a:link, .codeSnippetContainerTabActive a:visited, .codeSnippetContainerTabActive a:active {
            top: 2px;
            color: #707070;
            text-decoration: none;
            position: relative;
        }

        .codeSnippetContainerCodeContainer {
            top: -1px;
            clear: both;
            margin-bottom: 12px;
            border-top-color: #939393;
            border-right-color: #939393;
            border-bottom-color: #939393;
            border-left-color: #939393;
            border-top-width: 1px;
            border-right-width: 1px;
            border-bottom-width: 1px;
            border-left-width: 1px;
            border-top-style: solid;
            border-right-style: solid;
            border-bottom-style: solid;
            border-left-style: solid;
            position: relative;
        }

        .codeSnippetToolBar {
            width: auto;
            height: auto;
        }

        .codeSnippetToolBarText {
            top: -8px;
            width: auto;
            height: 0px;
            padding-right: 0px;
            padding-left: 0px;
            vertical-align: top;
            float: right;
            position: relative;
            background-color: rgb(255, 255, 255);
        }

            .codeSnippetToolBarText a:link, .codeSnippetToolBarText a:visited, .codeSnippetToolBarText a:active {
                color: #2a2a2a;
                padding-right: 8px;
                padding-left: 8px;
                font-family: "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif !important;
                font-size: 10px;
                font-style: normal !important;
                text-decoration: none;
                margin-right: 15px;
                margin-left: 15px;
                background-color: rgb(255, 255, 255);
            }

        .codeSnippetContainerCode {
            width: auto;
            padding-top: 10px;
            padding-right: 21px;
            padding-bottom: 10px;
            padding-left: 21px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
            margin-left: 0px;
        }

            .codeSnippetContainerCode div {
                padding-top: 0px;
                padding-right: 0px;
                padding-bottom: 0px;
                padding-left: 0px;
                margin-top: 0px;
                margin-right: 0px;
                margin-bottom: 0px;
                margin-left: 0px;
            }

            .codeSnippetContainerCode pre {
                line-height: 1;
                overflow: auto;
                padding-top: 5px;
                padding-right: 5px;
                padding-bottom: 5px;
                padding-left: 5px;
                font-family: Consolas,Courier,monospace;
                font-style: normal;
                font-weight: normal;
                margin-top: 0px;
                margin-right: 0px;
                margin-bottom: 0px;
                margin-left: 0px;
            }

        .sectionblock {
            padding-bottom: 20px;
            padding-left: 15px;
            display: block;
        }
    </style>
    <script src="jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function copyCode(id) {
            if (window.clipboardData) {
                var obj = document.getElementById(id); window.clipboardData.setData("Text", obj.innerText)
            }
        }

        jQuery.fn.contentChange = function (callback) {
            var elms = jQuery(this);
            elms.each(
              function (i) {
                  var elm = jQuery(this);
                  elm.data("lastContents", elm.html());
                  window.watchContentChange = window.watchContentChange ? window.watchContentChange : [];
                  window.watchContentChange.push({ "element": elm, "callback": callback });
              }
            )
            return elms;
        }
        setInterval(function () {
            if (window.watchContentChange) {
                for (i in window.watchContentChange) {
                    if (window.watchContentChange[i].element.data("lastContents") != window.watchContentChange[i].element.html()) {
                        window.watchContentChange[i].callback.apply(window.watchContentChange[i].element);
                        window.watchContentChange[i].element.data("lastContents", window.watchContentChange[i].element.html())
                    };
                }
            }
        }, 500);

        function SetTextValue(ttarget, ssender) {
            $(ttarget).text($(ssender).val());
        }
        function SetPeoplePickerValue(ptarget, psender) {
            $(ptarget).text($(psender).attr("description"));
        }
        function OnValueChange(target, sender, func) {
            $(sender).change(function () {
                func(target, this);
            });
        }
        function OnPeoplePickerValueChange(pctarget, pcsender, showAndHide) {
            $(pcsender).contentChange(function () {
                var object = $(pcsender + " #divEntityData")
                $targetObject = $(pctarget)
                if (object.attr("description") != null) {
                    if (showAndHide) {
                        $targetObject.parent().show();
                    }
                    $targetObject.text(object.attr("description"));
                }
                else {
                    if (showAndHide) {
                        $targetObject.parent().hide();
                    }
                }
            });
        }
        $(document).ready(function () {
            SetTextValue("#webappId", "#UIWebApplications", SetTextValue);
            SetTextValue("#language", "#DdLanguageWebTemplate", SetTextValue);
            SetTextValue("#compatibilityLevel", "#DdSiteCompatibilityLevel", SetTextValue);
            SetTextValue("#sitecollectiontemplate", "#LbWebTemplate", SetTextValue);
            OnValueChange("#webappId", "#UIWebApplications", SetTextValue);
            OnValueChange("#sitecollectionname", "#TxtCreateSiteTitle", SetTextValue);
            OnValueChange("#sitecollectionurl", "#TxtSiteName", SetTextValue);
            OnValueChange("#sitecollectiontemplate", "#LbWebTemplate", SetTextValue);
            OnValueChange("#language", "#DdLanguageWebTemplate", SetTextValue);
            OnValueChange("#compatibilityLevel", "#DdSiteCompatibilityLevel", SetTextValue);
            OnValueChange("#description", "#TxtCreateSiteDescription", SetTextValue);
            OnPeoplePickerValueChange("#sitecollectionowneralias", "#PickerOwnerWrapper", false);
            OnPeoplePickerValueChange("#sitecollectionsecondaryowneralias", "#PickerOwner2Wrapper", true);

        });

    </script>
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">


    <table border="0" cellspacing="0" cellpadding="0" class="ms-propertysheet" width="100%">
        <wssuc:ButtonSection runat="server" TopButtons="true" BottomSpacing="5" ShowSectionLine="false" ShowStandardCancelButton="false">
            <template_buttons>
			<asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="<%$Resources:wss,multipages_okbutton_text%>" id="BtnCreateSiteTop" accesskey="<%$Resources:wss,okbutton_accesskey%>" />
			<asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="<%$Resources:wss,multipages_cancelbutton_text%>" id="BtnCancelTop" accesskey="<%$Resources:wss,cancelbutton_accesskey%>" CausesValidation="false"/>
		</template_buttons>
        </wssuc:ButtonSection>
        <tr>
            <td colspan="2">
                <div class="codeSnippetContainer" id="code-snippet-1" xmlns="">
                    <div class="codeSnippetContainerTabs">
                        <div class="codeSnippetContainerTabActive" dir="ltr">PowerShell</div>
                    </div>
                    <div class="codeSnippetContainerCodeContainer">
                        <div class="codeSnippetToolBar">
                            <div class="codeSnippetToolBarText">
                                <a name="CodeSnippetCopyLink" title="Copy to clipboard." style="display: block;" href="javascript:copyCode('CodeSnippetContainerCode_716b65e1-6420-4125-8e3c-58aeb363c711');">Copy</a>
                            </div>
                        </div>
                        <div class="codeSnippetContainerCode" id="CodeSnippetContainerCode_716b65e1-6420-4125-8e3c-58aeb363c711" dir="ltr">
                            <div style="color: black;">
                                <pre><div>$wa = Get-SPWebApplication <span id="webappId"></span></div><div>New-SPSite "<span id="sitecollectionurl"></span>" -OwnerAlias "<span id="sitecollectionowneralias">user not found or people picker not ensured</span>" <span style="display:none;">-SecondaryOwnerAlias "<span id="sitecollectionsecondaryowneralias">user not found or people picker not ensured</span>"</span> -HostHeaderWebApplication $wa -Name "<span id="sitecollectionname"></span>" -Template "<span id="sitecollectiontemplate"></span>" -Language <span id="language"></span> -CompatibilityLevel "<span id="compatibilityLevel"></span>" -Description "<span id="description"></span>"</div></pre>
                            </div>

                        </div>
                    </div>
                </div>
            </td>
        </tr>
        
        <wssuc:InputFormSection runat="server"
            Title="Target webapplication"
            id="InputFormSection1">
            <template_description>
			Select the webapplication<br />
            If the dropdown is empty, create a webapplication without a host header
		</template_description>
            <template_inputformcontrols>
			<wssuc:InputFormControl runat="server"
				LabelText="Webapplication:">
				<Template_Control>
					<asp:DropDownList runat="server" id="UIWebApplications" ClientIDMode="Static" DataTextField="Name" DataValueField="Id" />
				</Template_Control>
			</wssuc:InputFormControl>
		</template_inputformcontrols>
        </wssuc:InputFormSection>
        <wssuc:InputFormSection runat="server"
            Title="<%$Resources:spadmin, createsite_idInputTitleTitleDesc%>"
            Description="<%$Resources:spadmin, createsite_idInputDescriptionTitleDesc%>"
            id="idTitleDescSection">
            <template_inputformcontrols>
			<wssuc:InputFormControl runat="server"
				LabelText="<%$Resources:spadmin, createsite_idInputLabelTitle%>">
				<Template_Control>
					<wssawc:InputFormTextBox title="<%$Resources:spadmin, createsite_TxtCreateSiteTitle_title%>" CssClass="ms-input" ClientIDMode="Static" ID="TxtCreateSiteTitle" Columns="35" Runat="server" MaxLength=255 />
					<wssawc:InputFormRequiredFieldValidator
						ID="ReqValTxtCreateSiteTitle"
						ControlToValidate="TxtCreateSiteTitle"
						ErrorMessage="<%$Resources:spadmin, createsite_titlerequired%>"
						Runat="server"/>
				</Template_Control>
			</wssuc:InputFormControl>
			<wssuc:InputFormControl runat="server"
				LabelText="<%$Resources:spadmin, multipages_description%>">
				<Template_Control>
					<wssawc:InputFormTextBox title="<%$Resources:spadmin, createsite_TxtCreateSiteDescription_title%>" ClientIDMode="Static" class="ms-input" ID="TxtCreateSiteDescription" Runat="server" TextMode="MultiLine" Columns="40" Rows="3"/>
				</Template_Control>
			</wssuc:InputFormControl>
		</template_inputformcontrols>
        </wssuc:InputFormSection>
        <wssuc:InputFormSection Title="<%$Resources:spadmin, createsite_siteadr_title%>" runat="server">
            <template_description>

		</template_description>
            <template_inputformcontrols>
			<wssuc:InputFormControl runat="server" LabelText="<%$Resources:spadmin, createsite_idUrl%>">
				<Template_Control>
					<wssawc:InputFormTextBox title="<%$Resources:spadmin, createsite_sitename%>" class="ms-input" ClientIDMode="Static" ID="TxtSiteName" Columns="18" Runat="server" MaxLength=128  />
                    <wssawc:InputFormCustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Url is all ready used" ControlToValidate="TxtSiteName" OnServerValidate="Validated_SiteUrl"></wssawc:InputFormCustomValidator>
				</Template_Control>
			</wssuc:InputFormControl>
		</template_inputformcontrols>
        </wssuc:InputFormSection>
        <wssuc:TemplatePickerControl id="InputFormTemplatePickerControl" runat="server"
            TemplateTypesToShow="RootWeb"
            HonorVisibilityFeatureDependencies="false"
            ShowCustomTemplates="true" ClientIDMode="Static" />

        <wssuc:InputFormSection
            Title="<%$Resources:spadmin, createsite_idWebAdminHeader%>"
            Description="<%$Resources:spadmin, Site_idWebAdminDescription%>"
            runat="server"
            id="idPrimaryAdministratorSection">
            <template_inputformcontrols>
				<wssuc:InputFormControl LabelText="<%$Resources:spadmin, createsite_idOwnerLogin%>"
					runat="server">
					<Template_Control>
                        <span id="PickerOwnerWrapper">
						<wssawc:PeopleEditor
						  AllowEmpty=false
						  SingleLine=true
						  ValidatorEnabled="true"
						  MultiSelect=false
						  id="PickerOwner"
						  runat="server"
						  SelectionSet="User"
						  />
                            </span>
					</Template_Control>
				</wssuc:InputFormControl>
		</template_inputformcontrols>
        </wssuc:InputFormSection>
        <wssuc:InputFormSection Title="<%$Resources:spadmin, createsite_ContactHeader%>"
            Description="<%$Resources:spadmin, Site_ContactDescription%>"
            runat="server"
            id="idSecondaryAdministratorSection">
            <template_inputformcontrols>
				<wssuc:InputFormControl LabelText="<%$Resources:spadmin, createsite_ContactLogin%>"
					runat="server">
					<Template_control>
                        <span id="PickerOwner2Wrapper">
						<wssawc:PeopleEditor
						  SingleLine=true
						  ValidatorEnabled="true"
						  MultiSelect=false
						  id="PickerOwner2"
						  runat="server"
                            SelectionSet="User"
						  />
                            </span>
					</Template_control>

				</wssuc:InputFormControl>
		</template_inputformcontrols>
        </wssuc:InputFormSection>
        <wssuc:ButtonSection runat="server" ShowStandardCancelButton="false">
            <template_buttons>
			<asp:Button UseSubmitBehavior="false" runat="server" OnClick="BtnCreateSite_Click" class="ms-ButtonHeightWidth" Text="<%$Resources:wss,multipages_okbutton_text%>" id="BtnCreateSite" accesskey="<%$Resources:wss,okbutton_accesskey%>" />
			<asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="<%$Resources:wss,multipages_cancelbutton_text%>" id="BtnCancel" accesskey="<%$Resources:wss,cancelbutton_accesskey%>" CausesValidation="false"/>
		</template_buttons>
        </wssuc:ButtonSection>
    </table>
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Create host named site collection
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
    Create host named site collection
</asp:Content>
